<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<!-- Light Box code -->
<link rel="stylesheet" href="../../CSS/lightbox.css" type="text/css" media="screen" />

<script type="text/javascript" src="../../js/prototype.js"></script>
<script type="text/javascript" src="../../js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="../../js/lightbox.js"></script>

<!-- End of Light box code -->
<?php 

session_start();
if(@$_SESSION['status'] == " ")
{
$_SESSION['status']=NULL;
}
?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cart</title>
<link href="../../CSS/Divlayouts.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#apDiv1 {
	position:absolute;
	width:963px;
	height:115px;
	z-index:6;
	left: 143px;
	top: 5px;
}
#apDiv2 {
	position:absolute;
	width:101px;
	height:80px;
	z-index:6;
	left: 397px;
	top: 27px;
}
#apDiv3 {
	position:absolute;
	width:766px;
	height:273px;
	z-index:6;
	left: 261px;
	top: 257px;
}
#apDiv4 {
	position:absolute;
	width:213px;
	height:227px;
	z-index:7;
	left: 19px;
	top: 24px;
}
#apDiv5 {
	position:absolute;
	width:321px;
	height:51px;
	z-index:1;
	left: 252px;
	top: 18px;
}
#apDiv6 {
	position:absolute;
	width:322px;
	height:166px;
	z-index:2;
	left: 252px;
	top: 90px;
}
#apDiv7 {
	position:absolute;
	width:153px;
	height:75px;
	z-index:1;
	left: 596px;
	top: 39px;
	text-align: left;
}
#apDiv8 {
	position:absolute;
	width:755px;
	height:94px;
	z-index:1;
	left: -584px;
	top: 244px;
}
#apDiv9 {
	position:absolute;
	width:956px;
	height:139px;
	z-index:7;
	left: -599px;
	top: 344px;
}
</style>
</head>


	
<body>
<pre><p>                          <a href="index.php"><img src="../Resources/eMart logo.png" width="170" height="67" alt="Logo" /></a>                                                                <a  class="linkunderline" href="customer_support.php">Customer Support</a>  |  <a class="linkunderline" href="Terms.php">Privacy Policy</a>
                                           <?php if ((@$_SESSION['status']== NULL)||(@$_SESSION['status']== "OUT")){echo"Welcome! <a href='login.php'>Sign in</a> or <a href='Register.php'>Register</a>";} else { echo "Welcome ".($_SESSION['fname'])." ".($_SESSION['lname']) ."<pre>                                  <a  class='underline' href='refresh.php'>Logout</a>    <a class='underline' href='editaccount.php' >My Account</a> </pre>" ; } ?> </pre>
<div style="background-image:url(../../Resources/Column%20Pannel.png); background-repeat:no-repeat"id="DivNews"></div>

<div id="DivHR"><hr/></div>
<div  style="background-image:url(../../Resources/Search%20Bar.png)" id="DivBar"></div>
<div id="DivSearchBar"> 
<form name="emartsearch" action="emartsearchresult.php" method="post">
    <select name="criteria">
        <option value="1">All Criterias</option>
        <option value="2">Product Name</option>
        <option value="3">Product Code</option>
        <option value="4">Category</option> 

    </select>
    <input type="text" style="width: 400px" value="Enter search term" size="25" maxlength="20" name="parameter" />
        <input type="submit" name="search" value="Search" />
</form></div>



<?php

echo $_SESSION['id']; //Erase when sending to troy r gavin

/*$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("store",$con) or die ("could not select DB!");


if(@$_POST['submitlg'])
{
	@$quantity = trim ($_POST['quantitylg']);
	
	if(isset($_POST['submitlg'])) // Note if this line starts to give trouble put it to submit
	{
		if(!$quantity)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantity))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantity < $_SESSION['pquantitylg'])
	{
		
	$_SESSION['pcostlg'] = $_SESSION['pcostlg'] * $quantity;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodelg']."','{$quantity}', '".$_SESSION['pcostlg']."')";
	
	
	mysql_query($query);
	
	}
	
}
mysql_close($con);
?>*/

//<?php
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitprocessor'])
{
	@$quantitypro = trim ($_POST['quantityprocessor']);
	
	if(isset($_POST['submitprocessor'])) // Note if this line starts to give trouble put it to submit
	{
		if(!$quantitypro)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantitypro))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantitypro < $_SESSION['pquantityprocessor'])
	{
		
	$_SESSION['pcostprocessor'] = $_SESSION['pcostprocessor'] * $quantitypro;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodeprocessor']."','{$quantitypro}', '".$_SESSION['pcostprocessor']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}
mysql_close($con);
?>

<?php
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitdf'])
{
	@$quantitydf = trim ($_POST['quantitydf']);
	
	if(isset($_POST['submitdf'])) // Note if this line starts to give trouble put it to submit
	{
		if(!$quantitydf)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantitydf))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantitydf < $_SESSION['pquantitydf'])
	{
		
	$_SESSION['pcostdf'] = $_SESSION['pcostdf'] * $quantitydf;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodedf']."','{$quantitydf}', '".$_SESSION['pcostdf']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}
mysql_close($con);
?>

<?php
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitbs'])
{
	@$quantitybs = trim ($_POST['quantitybs']);
	
	if(isset($_POST['submitbs'])) // Note if this line starts to give trouble put it to submit
	{
		if(!$quantitybs)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantitybs))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantitybs < $_SESSION['pquantitybs'])
	{
		
	$_SESSION['pcostbs'] = $_SESSION['pcostbs'] * $quantitybs;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodebs']."','{$quantitybs}', '".$_SESSION['pcostbs']."')";
	
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}
mysql_close($con);
?>

<?php
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitoven'])
{
	@$quantityov = trim ($_POST['quantityoven']);
	
	if(isset($_POST['submitoven'])) // Note if this line starts to give trouble put it to submit
	{
		if(!$quantityov)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantityov))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantityov < $_SESSION['pquantityoven'])
	{
		
	$_SESSION['pcostoven'] = $_SESSION['pcostoven'] * $quantityov;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodeoven']."','{$quantityov}', '".$_SESSION['pcostoven']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}

mysql_close($con);
?>

<?php
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitgr'])
{
	@$quantitygr = trim ($_POST['quantitygr']);
	
	if(isset($_POST['submitgr'])) // Note if this line starts to give trouble put it to submit
	{
		if(!$quantitygr)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantitygr))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantitygr < $_SESSION['pquantitygr'])
	{
		
	$_SESSION['pcostgr'] = $_SESSION['pcostgr'] * $quantitygr;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodegr']."','{$quantitygr}', '".$_SESSION['pcostgr']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}

mysql_close($con);
?>

<?php
//computers
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");


if(@$_POST['submitasus'])
{
	@$quantityasus = trim ($_POST['quantityasus']);
	
	if(isset($_POST['submitasus']))
	{
		if(!$quantityasus)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantityasus))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantityasus < $_SESSION['pquantityasus'])
	{
		
	$_SESSION['pcostasus'] = $_SESSION['pcostasus'] * $quantityasus;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodeasus']."','{$quantityasus}', '".$_SESSION['pcostasus']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}

mysql_close($con);
?>

<?php
//Computers
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");


if(@$_POST['submitlen'])
{
	@$quantitylen = trim ($_POST['quantitylen']);
	
	if(isset($_POST['submitlen']))
	{
		if(!$quantitylen)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantitylen))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantitylen < $_SESSION['pquantitylen'])
	{
		
	$_SESSION['pcostlen'] = $_SESSION['pcostlen'] * $quantitylen;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodelen']."','{$quantitylen}', '".$_SESSION['pcostlen']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}

mysql_close($con);
?>


<?php
//Computers
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");
if(@$_POST['submitali'])
{
	@$quantityali = trim ($_POST['quantityali']);
	
	if(isset($_POST['submitali']))
	{
		if(!$quantityali)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantityali))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantityali < $_SESSION['pquantityali'])
	{
		
	$_SESSION['pcostali'] = $_SESSION['pcostali'] * $quantityali;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodeali']."','{$quantityali}', '".$_SESSION['pcostali']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
	
}

mysql_close($con);
?>

<?php
//Computers
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitacer'])
{
	@$quantityacer = trim ($_POST['quantityacer']);
	
	if(isset($_POST['submitacer']))
	{
		if(!$quantityacer)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantityacer))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantityacer < $_SESSION['pquantityacer'])
	{
		
	$_SESSION['pcostacer'] = $_SESSION['pcostacer'] * $quantityacer;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodeacer']."','{$quantityacer}', '".$_SESSION['pcostacer']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}

mysql_close($con);
?>

<?php
//Computers
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitmac'])
{
	@$quantitymac = trim ($_POST['quantitymac']);
	
	if(isset($_POST['submitmac']))
	{
		if(!$quantitymac)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantitymac))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantitymac < $_SESSION['pquantitymac'])
	{
		
	$_SESSION['pcostmac'] = $_SESSION['pcostmac'] * $quantitymac;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodemac']."','{$quantitymac}', '".$_SESSION['pcostmac']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}

mysql_close($con);
?>


<?php
//MP3's
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitzun'])
{
	@$quantityzun = trim ($_POST['quantityzun']);
	
	if(isset($_POST['submitzun']))
	{
		if(!$quantityzun)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantityzun))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantityzun < $_SESSION['pquantityzun'])
	{
		
	$_SESSION['pcostzun'] = $_SESSION['pcostzun'] * $quantityzun;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodezun']."','{$quantityzun}', '".$_SESSION['pcostzun']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}
mysql_close($con);
?>

<?php
//MP3's
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitzen'])
{
	@$quantityzen = trim ($_POST['quantityzen']);
	
	if(isset($_POST['submitzen']))
	{
		if(!$quantityzen)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantityzen))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantityzen < $_SESSION['pquantityzen'])
	{
		
	$_SESSION['pcostzen'] = $_SESSION['pcostzen'] * $quantityzen;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodezen']."','{$quantityzen}', '".$_SESSION['pcostzen']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}
mysql_close($con);
?>

<?php
//MP3's
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitsony'])
{
	@$quantitysony = trim ($_POST['quantitysony']);
	
	if(isset($_POST['submitsony']))
	{
		if(!$quantitysony)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantitysony))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantitysony < $_SESSION['pquantitysony'])
	{
		
	$_SESSION['pcostsony'] = $_SESSION['pcostsony'] * $quantitysony;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodesony']."','{$quantitysony}', '".$_SESSION['pcostsony']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}
mysql_close($con);
?>



<?php
//MP3's
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitphil'])
{
	@$quantityphil = trim ($_POST['quantityphil']);
	
	if(isset($_POST['submitphil']))
	{
		if(!$quantityphil)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantityphil))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantityphil < $_SESSION['pquantityphil'])
	{
		
	$_SESSION['pcostphil'] = $_SESSION['pcostphil'] * $quantityphil;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodephil']."','{$quantityphil}', '".$_SESSION['pcostphil']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}
mysql_close($con);
?>

<?php
//MP3's
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

if(@$_POST['submitapp'])
{
	@$quantityapp = trim ($_POST['quantityapp']);
	
	if(isset($_POST['submitapp']))
	{
		if(!$quantityapp)
		{
			die("Quantity field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[1-9]{1}+$/", $quantityapp))
	{
		die("Does not match quantity criteria <b>NUMBERS ONLY</b>");
	}
	
	
	if( $quantityapp < $_SESSION['pquantityapp'])
	{
		
	$_SESSION['pcostapp'] = $_SESSION['pcostapp'] * $quantityapp;
	
	$query = "INSERT INTO cart (Member_Id, Product_Code, Product_Quantity, Product_Cost) VALUES ('".$_SESSION['id']."','".$_SESSION['pcodeapp']."','{$quantityapp}', '".$_SESSION['pcostapp']."')";
	
	
	mysql_query($query);
	
	}
	else
	{
		print"QUANTITY ENTERED EXCEEDS AMOUNT AVAILABLE";
	}
}
mysql_close($con);
?>


<?php

//Form on page to collect product code from user to remove it from cart

echo"<form action='cart.php' method='post'>";
echo"<br/>
    <br/>
    <h2>Enter Prouct code to remove it from cart</h2>
    <br/>
    Product Code: <input type='number' style='width: 200px' name='remove'/>";
	echo "<input type='submit' name='removal' value='Update cart' />";
	echo "\t <a href='checkout.php'>Checkout</a>";
	echo"<br/>
    <br/>";
	
	$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
	mysql_select_db ("web project",$con) or die ("could not select DB!");


$sql = "SELECT cart.Member_Id, products.ImageSmall, products.ProductName, cart.Product_Code, cart.Product_Quantity, cart.Product_Cost 
		FROM cart
		INNER JOIN products
		ON products.ProductCode = cart.Product_Code";

$sumsql = "SELECT SUM( Product_Cost ) AS Total FROM cart";

$sumresult = mysql_query($sumsql);

while($rows = mysql_fetch_array($sumresult))
		{
			 
			$tcost = $rows['Total'];
		}
		
$result = mysql_query($sql);

		
		echo "E- mart Shopping Cart";
		echo "<br>";
		echo "<br>";
		
		print "<table border=2>";
		print "<tr>";
		print "<td>Member ID</td>";
		print "<td>Product Image</td>";
		echo "<td>Product Name</td>";
		echo "<td>Product Code</td>";
		echo "<td>Product Quantity</td>";
		echo "<td>Product Cost</td>";
		print "</tr>";
		

		while($row = mysql_fetch_array($result))
		{
			print "<tr>";
			print "<td>"; 
			echo $row['Member_Id'];
			echo "</td> <td>";
			echo "<img src= '{$row['ImageSmall']}'>"; 
			echo "</td> <td>";
			echo $row['ProductName'];
			echo "</td> <td>";
			echo $row['Product_Code'];
			echo "</td> <td>";
			echo $row['Product_Quantity'];
			echo "</td><td>";
			echo $row['Product_Cost'];
			echo "</td>";
			print "</tr>";
		}
			mysql_close($con);
			
		
		print "</table>";
		
		print "The total cost of all item/s is \$$tcost";

$_SESSION['tcost'] = $tcost;
$quantity = NULL;
$_SESSION['id'] = NULL;
$_SESSION['pcodelg'] = NULL;
$_SESSION['pcostlg']= NULL;
	
    
 
echo"</form>";


@$removal = $_POST['removal'];

if(@$_POST['removal'])
{
	@$remove = trim ($_POST['remove']);
	
	if(isset($_POST['removal']))
	{
		if(!@$remove)
		{
			die("Removal field left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[a-zA-Z0-9-]{7,9}+$/", $remove))
	{
		die("Does not match quantity criteria <b>PRODUCT CODES ONLY</b>");
	}
	
	$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
	mysql_select_db ("web project",$con) or die ("could not select DB!");
	
	$sqld = "DELETE FROM cart WHERE Product_Code = '$remove'";
	
	if(isset($sqld))
	{
		echo"<meta http-equiv='refresh' content='0;url=cart.php'>";	
	}
	
	mysql_query($sqld);
	mysql_close($con);
}


?>





